import {Ref} from "vue"
import {IElsElem} from "../ElsElem"


export namespace IElsForm {
  export interface Props {
    modelValue?: Record<string, any>;
    column: Column;
    size?: "large" | "default" | "small";
    UIPluging?: UIPluging;
    autoClean?: boolean;
    params?:Record<string,any>
  }
  
  export interface ColumnItem extends IElsElem.Elem {
    tip?:string | ColumnTip
  }

  export interface ColumnTip extends Record<string,any> {
    // icon?:string | any
    content?:string
    // slot?:boolean | string
    // placement?:"left" | "right" | "bottom"
    placement?: "top" | "right" | "left" | "bottom" | "top-start" | "top-end" | "right-start" | "right-end" | "left-start" | "left-end" | "bottom-start" | "bottom-end"
  }

  export type Column = ColumnItem[]

  export interface Emits {
    (e: "update:modelValue", v: Record<string, any>): void;
    (e: "change", name: string, value: any): void;
  }
  
  export type UIPluging = (
    props: Props,
    cfg: UIPluginConfig,
    ext: Record<string, any>,
  ) => {
    elem: IElsElem.Elem;
    context: IElsElem.Context;
    formRef: Ref<any>;
    formApi: (name: string, ...args: any) => any;
    validate: (...args: any) => Promise<any>;
  };
  
  export interface UIPluginConfig {
    formProps: Set<string>;
    formData: Ref<Record<string, any>>;
    emitChange: (prop: string, val: any) => void;
  }
}
